package com.milotnt.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.milotnt.form.AdminForm;
import com.milotnt.mapper.AdminMapper;
import com.milotnt.pojo.AdminEntity;
import com.milotnt.service.AdminService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Slf4j
@Transactional
public class AdminServiceImpl extends ServiceImpl<AdminMapper, AdminEntity> implements AdminService {

    @Autowired
    private AdminMapper adminMapper;

    @Override
    public AdminEntity adminLogin(AdminForm admin) {
        LambdaQueryWrapper<AdminEntity> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(AdminEntity::getAdminAccount, admin.getAdminAccount())
                    .eq(AdminEntity::getAdminPassword, admin.getAdminPassword());
        return adminMapper.selectOne(queryWrapper);
    }
}
